package cn.ecut.Dao;

import java.sql.*;
public class cusshow {
    public String[] cusshowinfo(String name) throws SQLException, ClassNotFoundException {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
                "databaseName=thirdtest;user=mx;password=wanyuwen2000@;";/*注册驱动*/
        Connection coon = DriverManager.getConnection(connectionUrl);/*链接connection*/
        Statement state = coon.createStatement();
        String sql = "select * from cusinfo";
        ResultSet rs = state.executeQuery(sql);
        int flag = 0;
        while (rs.next()) {
            if (name.equals(rs.getString(1))) {
                flag = 1;
                String[] s1 = new String[5];
                for (int i = 0; i < 5; i++) {
                    s1[0] = rs.getString(1);
                    s1[1] = rs.getString(2);
                    s1[2] = rs.getString(3);
                    s1[3] = rs.getString(4);
                    s1[4] = rs.getString(5);
                    System.out.printf(rs.getString(i+1));
                }
                return s1;
            }
        }
        if (flag == 0)
            System.out.print("数据库没有这个人，查询错误");
        return null;
    }
}



